<?php


namespace app\admin\controller;


use think\cache\driver\Redis;
use think\Controller;
use app\model\Admin;
class Index extends Allow
{
    /**
     * 列表展示
     * @return \think\response\View
     */
    public function index()
    {
        $data = getMenuByPid(0);
        $admin_id = session("admin_id");
        $admin = Admin::find($admin_id);
        $this->assign([
            'data' => $data,
            'admin' => $admin
        ]);
        return view("index");
    }

    /**
     * 欢迎页面
     * @return \think\response\View
     */
    public function welcome(){
        return "hello world";
        /*$admin_id = session("admin_id");
        $admin = Admin::find($admin_id);
        $key = date("Y-m-d",time());
        $total_key = 'total_key';
        $redis = new Redis();
        $today = $redis->get($key) ?? 0;
        $total = $redis->get($total_key);
//        dump($total);die;
        $this->assign([
            'admin' => $admin,
            'last_login_time' => session("last_login_time"),
            'today' => number_format($today),
            'total' => number_format($total),
        ]);
        return view('welcome');*/
    }
/*    //今天新增人数
    public function today()
    {
        $redis = new Redis();
        $num = $redis->get("today:num");
        if(empty($num)){
            $num += 1;
            $redis->set("today:num",$num);
            return $num;
        }else{
            $num += 1;
            $redis->set("today:num",$num);
            return $num;
        }
    }*/
/*    //获取今日访问量
    public function getToDayNum()
    {
        $redis = new Redis();
        $num = $redis->get("today:num");
        return $num;
    }
    //清除每天的访问量
    public function clearVisit()
    {
        $redis = new Redis();
        $redis->set("today:num",0);
    }*/
}